<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.lft.examsys.util.DateTimeUtil" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>Login</title>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/home.css">
    <link rel="stylesheet" href="css/login.css">
    <jsp:include page="/layout/_imports.jsp"></jsp:include>
    <style>
        .papers {
            width: 80%;
            margin: 0 auto;
            text-align: center;
        }
        .begin_paper a {
            text-decoration: none;
            color: #fff;
        }
    </style>
</head>
<body>
<jsp:include page="/layout/_nav.jsp"></jsp:include>
<c:if test="${user==null}">
    <jsp:include page="/user/login.jsp"></jsp:include>
</c:if>
<c:if test="${user != null && !user.admin}">
    <div class="papers">
        <h2>以下是当前考试的试卷，请同学们抓紧试卷参加！</h2>
        <table class="table" style="text-align: center">
            <thead class="thead-dark">
            <tr>
                <th scope="col">序号</th>
                <th scope="col">试卷名</th>
                <th scope="col">考试开始时间</th>
                <th scope="col">时限</th>
                <th scope="col">试题数</th>
                <th scope="col">操作</th>
            </tr>
            </thead>
            <tbody>

            <c:forEach items="${papers}" var="i" varStatus="paper">
                <tr>
                    <th scope="row">${paper.index + 1}</th>
                    <td>${i.title}</td>
                    <td class="begin_time"><fmt:formatDate value="${i.begin}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                    <td class="limitation">${i.limitation}</td>
                    <td>${itemsCount.get(i.id) != null?itemsCount.get(i.id):"0"}</td>
                    <td>
                        <div>
                            <input type="hidden" name="id" value="${i.id}">
                            <button class="btn btn-primary begin_paper">
                                <a href="/exam/begin?id=${i.id}">
                                    已开始
                                </a>
                            </button>
                        </div>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</c:if>

<c:if test="${user.admin}">
    <h2 style="margin: 0 auto; width: 80%">欢迎您，管理员。现在你可以在导航栏管理权限、试卷以及题目啦！</h2>
</c:if>
</body>
</html>
